import { OrderData, OrderDataParam } from '@/types/orderList'
import { OrderDetailData, OrderDetailParam } from '@/types/orderList/orderDetail'
import fetch, { RequestContentType } from './index'

type OrderBaseResponse = {
  status: number
  data: OrderData
}

type OrderDetailResponse = {
  status: number
  data: OrderDetailData
}
/**
 *获取订单里列表
 * @param param OrderDataParam = {
    curpage: number;
    perpage: number;
    filterNum: number;
    type: EOrderParamType;
    'X-Businessline-Id': XBusinesslineId;}
 * @returns OrderBaseResponse
 */
export async function getOrderList(param: OrderDataParam): Promise<OrderBaseResponse> {
  const { data } = await fetch.post<OrderBaseResponse>(
    '/api/ocenter/Touch/OrderList/index',
    {
      ...param,
    },
    { contentType: RequestContentType.FORM_URLENCODED },
  )
  return data
}
/**
 * 获取订单详细数据
 * @param param OrderDetailParam = {
    orderNum: string;
    'X-Businessline-Id': XBusinesslineId;
}
 * @returns OrderDetailResponse
 */
export async function getOrderDetail(param: OrderDetailParam): Promise<OrderDetailResponse> {
  const { data } = await fetch.post<OrderDetailResponse>(
    '/api/ocenter/Touch/OrderDetail/index',
    {
      ...param,
    },
    { contentType: RequestContentType.FORM_URLENCODED },
  )
  return data
}
